//
//  LAB_CropImageViewController.m
//  Camera
//
//  Created by Bodi on 16/8/11.
//  Copyright © 2016年 葛海一. All rights reserved.
//

#import "LAB_CropImageViewController.h"
#import "LAB_FiltersViewController.h"
@interface LAB_CropImageViewController ()

@end

@implementation LAB_CropImageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self setNavViewUI];
    
    [self addChildViewController:self.clipImageVC];
}
#pragma mark - 设置页面导航Nav
- (void)setNavViewUI {
    [self addNavViewTitle:@"裁剪图片"];
    [self addBackButton];
    [self addNextButton];
    [self.nextBtn addTarget:self action:@selector(nextBtnClick) forControlEvents:(UIControlEventTouchUpInside)];
}

//  “继续”
- (void)nextBtnClick {
    LAB_FiltersViewController *filtersVC = [[LAB_FiltersViewController alloc]init];
    filtersVC.filtersImg = [self.clipImageVC clippingImage];
    [self.navigationController pushViewController:filtersVC animated:YES];
}

#pragma mark - 设置裁剪视图
- (LAB_ClipImageViewController *)clipImageVC {
    if (!_clipImageVC) {
        _clipImageVC = [[LAB_ClipImageViewController alloc] init];
        _clipImageVC.view.frame = CGRectMake(0, 50, WIDTH, HEIGHT - 50);
        _clipImageVC.clipImageRect = CGRectMake(0, HEIGHT/5, WIDTH, WIDTH);  //  裁剪的大小
        
        UIImageView * coverView = [[UIImageView alloc] initWithFrame:_clipImageVC.clipImageRect];
        [_clipImageVC.view addSubview:coverView];
        [_clipImageVC.clipImageView setNeedsDisplay];
        [self.view addSubview:_clipImageVC.view];
    }
    return _clipImageVC;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
